package com.mind.adjust.service.impl;

import com.mind.system.domain.AjAttachCate;
import com.mind.adjust.mapper.AjAttachCateMapper;
import com.mind.adjust.service.AjAttachCateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 附件类型(AjAttachCate)表服务实现类
 *
 * @author makejava
 * @since 2024-07-11 17:39:44
 */
@Service("attachCateService")
public class AjAttachCateServiceImpl implements AjAttachCateService {
    @Autowired
    private AjAttachCateMapper attachCateMapper;

    /**
     * 查询附件类型信息集合
     * 
     * @param attachCate 附件类型信息
     * @return 附件类型信息集合
     */
    @Override
    public List<AjAttachCate> selectAttachCateList(AjAttachCate attachCate)
    {
        return attachCateMapper.selectAttachCateList(attachCate);
    }

    /**
     * 通过附件类型ID查询附件类型信息
     * 
     * @param attachCateId 附件类型ID
     * @return 角色对象信息
     */
    @Override
    public AjAttachCate selectAttachCateById(Long attachCateId)
    {
        return attachCateMapper.selectAttachCateById(attachCateId);
    }

    /**
     * 删除附件类型信息
     * 
     * @param attachCateId 附件类型ID
     * @return 结果
     */
    @Override
    public int deleteAttachCateById(Long attachCateId)
    {
        return attachCateMapper.deleteAttachCateById(attachCateId);
    }

    /**
     * 批量删除附件类型信息
     * 
     * @param attachCateIds 需要删除的附件类型ID
     * @return 结果
     */
    @Override
    public int deleteAttachCateByIds(Long[] attachCateIds)
    {
        return attachCateMapper.deleteAttachCateByIds(attachCateIds);
    }

    /**
     * 新增保存附件类型信息
     * 
     * @param attachCate 附件类型信息
     * @return 结果
     */
    @Override
    public int insertAttachCate(AjAttachCate attachCate)
    {
        return attachCateMapper.insertAttachCate(attachCate);
    }

    /**
     * 修改保存附件类型信息
     * 
     * @param attachCate 附件类型信息
     * @return 结果
     */
    @Override
    public int updateAttachCate(AjAttachCate attachCate)
    {
        return attachCateMapper.updateAttachCate(attachCate);
    }
    
    /**
     * 批量插入
     *
     * @param attachCateList 附件类型信息
     * @return 结果
     */
    @Override
    public int batchInsert(List<AjAttachCate> attachCateList) {
        int size = 0;
        for(AjAttachCate attachCate: attachCateList) {
            if (attachCateMapper.selectAttachCateByName(attachCate.getName()) == null){
                attachCateMapper.insertAttachCate(attachCate);
                size ++;
            }
        }
        return size;
    }
}
